{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pygdf as cudf\n",
    "import pyblazing\n",
    "\n",
    "column_names = ['n_nationkey', 'n_name', 'n_regionkey', 'n_comments']\n",
    "column_types = ['int32', 'int64', 'int32', 'int64']\n",
    "nation_gdf = cudf.read_csv(\"../data/nation.psv\", delimiter='|',\n",
    "                           dtype=column_types, names=column_names)\n",
    "\n",
    "print(nation_gdf)\n",
    "\n",
    "tables = {'nation': nation_gdf}\n",
    "sql = 'select n_nationkey, n_regionkey, n_nationkey + n_regionkey as addition from main.nation'\n",
    "result_gdf = pyblazing.run_query(sql, tables)\n",
    "\n",
    "print(sql)\n",
    "print(result_gdf)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "import pyblazing\n",
    "\n",
    "column_names = ['n_nationkey', 'n_name', 'n_regionkey', 'n_comments']\n",
    "column_types = {'n_nationkey': 'int32', 'n_regionkey': 'int64'}\n",
    "nation_df = pd.read_csv(\"../data/nation.psv\", delimiter='|',\n",
    "                        dtype=column_types, names=column_names)\n",
    "nation_df = nation_df[['n_nationkey', 'n_regionkey']]\n",
    "\n",
    "print(nation_df)\n",
    "\n",
    "tables = {'nation': nation_df}\n",
    "sql = 'select n_nationkey, n_regionkey, n_nationkey + n_regionkey as addition from main.nation'\n",
    "result_gdf = pyblazing.run_query_pandas(sql, tables)\n",
    "\n",
    "print(sql)\n",
    "print(result_gdf)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pyarrow as pa\n",
    "import pyblazing\n",
    "\n",
    "arrow_table = pa.RecordBatchStreamReader('../data/gpu.arrow').read_all()\n",
    "df = arrow_table.to_pandas()\n",
    "df = df[['swings', 'tractions']]\n",
    "print(df)\n",
    "\n",
    "tables = {'gpu_info': df}\n",
    "sql = 'select swings+1, tractions+10 from main.gpu_info'\n",
    "result_gdf = pyblazing.run_query_pandas(sql, tables)\n",
    "\n",
    "print(sql)\n",
    "print(result_gdf)\n"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.5.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
